<template>
  <Upload
    :action="uploadFileUrl"
    :data="data"
    :headers="headers"
    :disabled="disabled"
    v-model="fileList"
    @error="onError"
    @success="onSuccess"
    name="file"
    method="post"
    @progress="onProgress"
    @beforeUpload="beforeUpload"
    @start="onStart"
    @click="onClick"
    listType="text"
    @updateModelValue="handleChange"
    :multiple="true"
  >
    <template v-slot:description>
      <span>支持扩展名.jpg{{fileList}}</span>
    </template>
  </Upload>
</template>

<script>
import { getToken } from "@/utils/auth";
import { Message } from "@uni/vue";
import request from "@/utils/request";
export default {
  data() {
    return {
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
      data: {},
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      disabled: false,
      fileList: [],
    }
  },
  methods: {
    onError(e) {
      console.log('e', onError);
    },
    onSuccess(b, r) {
      console.log('success', b, r);
    },
    beforeUpload(file, files,callback) {
      console.log('file123', file, files);
      return callback(file);
    },
    onProgress(a, b) {
      console.log('onProgress', a, b);
    },
    onStart(file) {
      console.log('==start', file);
    },
    onClick(file,evt) {
      console.log("点击了:",file)
    },
    handleChange(files) {
      console.log('==updateModelValue', files);
    },
  },
}
</script>